""" System imports """
import os,sys
import logging

""" Other modules """
import pygame
import pickle

""" Game """
from constants import *
from mixboard import mixboard
import inputhandler
#import resourcemanager

""" Set up logging """
_log = logging.getLogger("epicquest.session")
_log.debug("Initializing Session")

class SessionLoader():
    
    def loadSession(self, filename = "session.save"):
        file = open(filename, 'r')
        return pickle.load(file)
        
    def saveSession(self, session, filename):
        file = open(filename, 'w')
        pickle.dump(session, file)

class Session():
    
    def __init__(self):
        self.state = {}
        
    def get_state(self, key):
        if self.state.has_key(key):
            return self.state.get(key)
        return None
    
    """ Mostly an excuse to use the python zip function. Its pretty. """
    def mass_update_state(self, keys, values):
        for key, value in zip(keys, values):
            self.state[key] = value
        
    def update_state(self, key, value):
        self.state[key] = value
        #print "Setting " + key + " to " + str(value)
        
    def reset_session(self):
        """ Reset the session completely. Probably not what you mean to do. Think thrice."""
        self.state = {}
        
    def end_session(self):
        mixboard.fadeout_music(2000)
        